/******************************************************************************
 * Copyright (C) 2017 Chengdu Dlhd information industry co. LTD.
 * All Rights Reserved.
 * 本软件为成都顶联互动信息产业有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、复制、修改或发布本软件.
 *****************************************************************************/
package net.dgg.dggcloud.service.iboss.service.common;

import net.dgg.dggcloud.service.iboss.constant.ScStatusConstant;
import net.dgg.dggcloud.service.iboss.constant.ScWorkingConstant;
import net.dgg.dggcloud.service.iboss.dao.common.WorkBentchDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class WorkBentchService {
    @Autowired
    private WorkBentchDao workBentchDao;

    public Integer getWorkBentchNum(Map paramMap) {
        synchronized (this) {
            Integer i = null;
            String code = null == paramMap.get("code") ? "" : paramMap.get("code").toString();
            if (code.equals(ScWorkingConstant.WORKING_RECEIVE_NUM)) {//接单量
                paramMap.put("status", ScStatusConstant.ORDER_ANANDON);//接单量=生产订单-废单
                i = workBentchDao.countReceiveNum(paramMap);

            } else if (code.equals(ScWorkingConstant.WORKING_SUBMIT_NUM)) {//报审量
                i = workBentchDao.countSubmitNum(paramMap);

            } else if (code.equals(ScWorkingConstant.WORKING_SUBMIT_OK)) {//报审通过
                i = workBentchDao.countSubmitOK(paramMap);

            } else if (code.equals(ScWorkingConstant.WORKING_ORDER_COMPLETE)) {//成单量
                paramMap.put("status", ScStatusConstant.ORDER_COMPLETE);//已成单
                i = workBentchDao.countOrderCompleteNum(paramMap);

            } else if (code.equals(ScWorkingConstant.WORKING_LOAN_AMOUNT)) {//放款金额
                paramMap.put("status", ScStatusConstant.ORDER_COMPLETE);//已成单
                i = workBentchDao.countLoanAmountNum(paramMap) / 100;

            } else if (code.equals(ScWorkingConstant.WORKING_ORDER_ABANDON)) {//已废单
                paramMap.put("status", ScStatusConstant.ORDER_ANANDON);//已废单
                i = workBentchDao.countAbandonNum(paramMap);

            } else if (code.equals(ScWorkingConstant.WORKING_ORDER_RETURENED)) {//已退单
                paramMap.put("status", ScStatusConstant.ORDER_RETURENED);//已退单
                i = workBentchDao.countReturenedNum(paramMap);

            }

            return i;
        }
    }
}
